<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>GRForest</title>
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="GRForest";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../mmj/verify/GrammaticalParser.html" title="interface in mmj.verify"><span class="strong">Prev Class</span></a></li>
<li><a href="../../mmj/verify/GRNode.html" title="class in mmj.verify"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?mmj/verify/GRForest.html" target="_top">Frames</a></li>
<li><a href="GRForest.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">mmj.verify</div>
<h2 title="Class GRForest" class="title">Class GRForest</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>mmj.verify.GRForest</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">GRForest</span>
extends java.lang.Object</pre>
<div class="block">GRForest is a collection of static functions that operate on GRNode Trees.
 <p>
 Each tree's root is stored in mmj.lang.Cnst.gRRoot(dot).
 <p>
 A tree contains every Notation Grammar Rule that begins with the gRRoot's
 Cnst. Each leaf node has a reference (pointer) to a sub-tree, and so on. This
 enables all Rules whose expressions begin with "(" to share a common root.
 <p>
 The purpose of GRForest and GRNode was to provide a searchable repository of
 NotationRule information, and it is used for that purpose in
 <a href="../../mmj/verify/BottomUpParser.html" title="class in mmj.verify"><code>BottomUpParser</code></a> However, the Bottom Up algorithm is too inefficient
 for Metamath's set.mm and has been "deprecated" (to put it politely), in
 favor of <a href="../../mmj/verify/EarleyParser.html" title="class in mmj.verify"><code>EarleyParser</code></a>.
 <p>
 So, GRForest and GRNode are teetering on obsolescence and could be removed
 from without too much trouble. The only use for them still is checking for
 duplicate Rule expressions, and there is obviously a cheaper way to do that
 than with these things...(I'm guessing that since each GrammarRule carries
 its own expression that the hash code for each rule could be pre-computed and
 even stored, if desired, and then used as the key to a HashSet. Bada bing,
 bada boom.)
 <p>
 Therefore, I am not going to document these any further.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!--   -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../mmj/verify/GRForest.html#GRForest()">GRForest</a></strong>()</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a></code></td>
<td class="colLast"><code><strong><a href="../../mmj/verify/GRForest.html#addNotationRule(mmj.lang.Cnst[], mmj.verify.NotationRule)">addNotationRule</a></strong>(<a href="../../mmj/lang/Cnst.html" title="class in mmj.lang">Cnst</a>[]&nbsp;ruleFormatExpr,
               <a href="../../mmj/verify/NotationRule.html" title="class in mmj.verify">NotationRule</a>&nbsp;notationRule)</code>
<div class="block">
 get root, blow up if helpful to consistency;
 find last element of input expr that has a node under the forest
 root;
 if last element of input expr is the final element of the array and
 it already has a NotationRule return the found node -- but if the
 NotationRule is null, update the rule with the input rule and return the
 found node.
 prepare a linked chain of all nodes that do not already exist and
 splice them into the forest, returning the last node to the caller.
 </div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>protected static <a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a></code></td>
<td class="colLast"><code><strong><a href="../../mmj/verify/GRForest.html#addToTree(mmj.lang.Cnst, mmj.verify.GRNode)">addToTree</a></strong>(<a href="../../mmj/lang/Cnst.html" title="class in mmj.lang">Cnst</a>&nbsp;elementCnst,
         <a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;oldRoot)</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a></code></td>
<td class="colLast"><code><strong><a href="../../mmj/verify/GRForest.html#findCnstSubSeq(mmj.verify.GRNode, mmj.lang.Cnst[], int, int)">findCnstSubSeq</a></strong>(<a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;root,
              <a href="../../mmj/lang/Cnst.html" title="class in mmj.lang">Cnst</a>[]&nbsp;ruleFormatExpr,
              int&nbsp;seqNext,
              int&nbsp;seqLast)</code>
<div class="block">searches GrNode tree/subtree down through the "forest" of trees.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../mmj/verify/NotationRule.html" title="class in mmj.verify">NotationRule</a></code></td>
<td class="colLast"><code><strong><a href="../../mmj/verify/GRForest.html#findLen1CnstNotationRule(mmj.verify.GRNode, mmj.lang.Cnst)">findLen1CnstNotationRule</a></strong>(<a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;root,
                        <a href="../../mmj/lang/Cnst.html" title="class in mmj.lang">Cnst</a>&nbsp;cnst)</code>
<div class="block">searches GrNode tree for a length of 1 Notation Rule matching the input
 Cnst.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.util.Collection&lt;<a href="../../mmj/verify/NotationRule.html" title="class in mmj.verify">NotationRule</a>&gt;</code></td>
<td class="colLast"><code><strong><a href="../../mmj/verify/GRForest.html#getRuleCollection(mmj.verify.GRNode)">getRuleCollection</a></strong>(<a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;root)</code>&nbsp;</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!--   -->
</a>
<h3>Constructor Detail</h3>
<a name="GRForest()">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>GRForest</h4>
<pre>public&nbsp;GRForest()</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="findCnstSubSeq(mmj.verify.GRNode, mmj.lang.Cnst[], int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>findCnstSubSeq</h4>
<pre>public static&nbsp;<a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;findCnstSubSeq(<a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;root,
                    <a href="../../mmj/lang/Cnst.html" title="class in mmj.lang">Cnst</a>[]&nbsp;ruleFormatExpr,
                    int&nbsp;seqNext,
                    int&nbsp;seqLast)</pre>
<div class="block">searches GrNode tree/subtree down through the "forest" of trees. Each
 element of the input Cnst array represents a level of the forest, with
 ruleFormatExpr[0] in the top tree -- the matching GRNode contains a link
 down to the root of the tree in the level below, which represents the
 Cnst values in a ruleFormatExpr[1] that begin with the parent level's
 Cnst. In other words, each tree node can point to a tree below it -- as
 well as having left/right/parent/child pointers to GRNodes within the
 current level's tree.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>root</code> - the root node</dd><dd><code>ruleFormatExpr</code> - an array containing the sequence to search for</dd><dd><code>seqNext</code> - the start index into ruleFormatExpr</dd><dd><code>seqLast</code> - the end index into ruleFormatExpr</dd>
<dt><span class="strong">Returns:</span></dt><dd>the GRNode containing the match, or <code>null</code></dd></dl>
</li>
</ul>
<a name="findLen1CnstNotationRule(mmj.verify.GRNode, mmj.lang.Cnst)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>findLen1CnstNotationRule</h4>
<pre>public static&nbsp;<a href="../../mmj/verify/NotationRule.html" title="class in mmj.verify">NotationRule</a>&nbsp;findLen1CnstNotationRule(<a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;root,
                                    <a href="../../mmj/lang/Cnst.html" title="class in mmj.lang">Cnst</a>&nbsp;cnst)</pre>
<div class="block">searches GrNode tree for a length of 1 Notation Rule matching the input
 Cnst.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>root</code> - the root node</dd><dd><code>cnst</code> - the Cnst to search for</dd>
<dt><span class="strong">Returns:</span></dt><dd>the associated NotationRule</dd></dl>
</li>
</ul>
<a name="addNotationRule(mmj.lang.Cnst[], mmj.verify.NotationRule)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addNotationRule</h4>
<pre>public static&nbsp;<a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;addNotationRule(<a href="../../mmj/lang/Cnst.html" title="class in mmj.lang">Cnst</a>[]&nbsp;ruleFormatExpr,
                     <a href="../../mmj/verify/NotationRule.html" title="class in mmj.verify">NotationRule</a>&nbsp;notationRule)</pre>
<div class="block"><ol>
 <li>get root, blow up if helpful to consistency;</li>
 <li>find last element of input expr that has a node under the forest
 root;</li>
 <li>if last element of input expr is the final element of the array and
 it already has a NotationRule return the found node -- but if the
 NotationRule is null, update the rule with the input rule and return the
 found node.</li>
 <li>prepare a linked chain of all nodes that do not already exist and
 splice them into the forest, returning the last node to the caller.</li>
 </ol></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>ruleFormatExpr</code> - the expression to add.</dd><dd><code>notationRule</code> - the NotationRule for the expression</dd>
<dt><span class="strong">Returns:</span></dt><dd>tailNode of chain -- if returned node's NotationRule differs from
         input, then the input is a duplicate (error); otherwise the
         returned node is new and good.</dd></dl>
</li>
</ul>
<a name="addToTree(mmj.lang.Cnst, mmj.verify.GRNode)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addToTree</h4>
<pre>protected static&nbsp;<a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;addToTree(<a href="../../mmj/lang/Cnst.html" title="class in mmj.lang">Cnst</a>&nbsp;elementCnst,
               <a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;oldRoot)
                           throws java.lang.IllegalArgumentException</pre>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code></dd></dl>
</li>
</ul>
<a name="getRuleCollection(mmj.verify.GRNode)">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getRuleCollection</h4>
<pre>public static&nbsp;java.util.Collection&lt;<a href="../../mmj/verify/NotationRule.html" title="class in mmj.verify">NotationRule</a>&gt;&nbsp;getRuleCollection(<a href="../../mmj/verify/GRNode.html" title="class in mmj.verify">GRNode</a>&nbsp;root)</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-all.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../mmj/verify/GrammaticalParser.html" title="interface in mmj.verify"><span class="strong">Prev Class</span></a></li>
<li><a href="../../mmj/verify/GRNode.html" title="class in mmj.verify"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?mmj/verify/GRForest.html" target="_top">Frames</a></li>
<li><a href="GRForest.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
